# 初始余额
money = 0

#银行卡密码
key=123456

#操作界面
def start(money):
    import random
    while True:
        print("=" * 30 + "欢迎来到招商银行" + "=" * 30)
        print('{0:<10} {1:<30} {2:<30} {3:10}'.format("","1.查看账户余额","2.存款",""))
        print('{0:<10} {1:<34} {2:<30} {3:10}'.format("","3.取款","4.退卡",""))
        print("=" * 76)
        do=input("请选择您的操作：")
        if do=="1":
            print("您当前的余额是："+str(money)+"元")
        elif do=="2":
            print("请将钱放入取钞口")
            moneyCun=random.randrange(100,20000,100)
            print("请确认您要存入的金额是："+str(moneyCun))
            dodo=input("按1确认,按2取消：")
            if dodo=="1":
                print("存款成功！")
                money+=moneyCun
            elif dodo=="2":
                print("存款取消，请取出")
            else:
                print("无效操作，请重新选择！")
        elif do=="3":
            moneyQu=input("请输入您要取出的金额：")
            if 0<int(moneyQu)<=20000:
                dodo = input("按1确认,按2取消：")
                if dodo == "1":
                    if money>int(moneyQu):
                        print("取款成功，请在出钞口取走现金！")
                        money-=int(moneyQu)
                    else:
                        print("您的账户余额不足")
                elif dodo == "2":
                    print("取款取消")
            else:
                print("单笔金额至少100元，且不得超过2万元")
        elif do=="4":
            print("退卡成功，请在出卡口取走卡片!")
            break
        else:
            print("======== 无效操作，请重新选择！ ========")


#验证密码函数
def secret(key):
    keyShu = input("请输入您的账户密码：")
    keyInt = int(keyShu)
    if keyInt==key:
        start(money)
    elif keyInt!=key:
        print("您的密码错误")
        secret(key)


#首页界面
print("=" * 30 + "欢迎来到招商银行" + "=" * 30)
print("卡片读取成功！")
secret(key)


